﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace mainAppView
{
    public partial class storyForm : Form
    {
        private Button callerButton;
        public storyForm()
        {
            InitializeComponent();
        }

        public storyForm(Button button)
        {
            InitializeComponent();
            callerButton = button;
            textBox1.Text = callerButton.Text;
        }

        private void storyForm_Load(object sender, EventArgs e)
        {
            textBox1.MouseEnter += new EventHandler(mainAppView.Keyboard.TouchScreenKeyboard.Start);

            if (this.Location.Y + this.Size.Height > (int)(mainAppView.Keyboard.TouchScreenKeyboard._InstanceObject.Top))
            {

                int tempY = (int)(Screen.PrimaryScreen.Bounds.Height - mainAppView.Keyboard.TouchScreenKeyboard._InstanceObject.Height - this.Size.Height);
                this.Location = new Point(this.Location.X, tempY);
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
           callerButton.Text = textBox1.Text;
           if (mainAppView.Keyboard.TouchScreenKeyboard._InstanceObject != null)
           {
               mainAppView.Keyboard.TouchScreenKeyboard._InstanceObject.Hide();
               mainAppView.Keyboard.TouchScreenKeyboard.isActive = false;
           }
           this.Dispose();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (mainAppView.Keyboard.TouchScreenKeyboard._InstanceObject != null)
            {
                mainAppView.Keyboard.TouchScreenKeyboard._InstanceObject.Hide();
                mainAppView.Keyboard.TouchScreenKeyboard.isActive = false;
            }
            this.Dispose();
        }


        void textBox1_Click(object sender, EventArgs e)
        {
            if (mainAppView.Keyboard.TouchScreenKeyboard._InstanceObject != null)
            {
                if (this.Location.Y + this.Size.Height > (int)(mainAppView.Keyboard.TouchScreenKeyboard._InstanceObject.Top))
                {
                    
                    int tempY = (int)(Screen.PrimaryScreen.Bounds.Height - mainAppView.Keyboard.TouchScreenKeyboard._InstanceObject.Height - this.Size.Height);
                    this.Location = new Point(this.Location.X, tempY);
                }
            }
        }


        void storyForm_LostFocus(object sender, System.EventArgs e)
        {
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }
        
    }
}
